//kind.js
const APP_ID = 'wxbc481e689bab7910'; //输入小程序appid  
const APP_SECRET = '0925cdf5baa29c3521c0625831c1b378'; //输入小程序app_secret  
var OPEN_ID = ''; //储存获取到openid  
var SESSION_KEY = ''; //储存获取到session_key  
var app = getApp();
Page({
  data: {
    userInfo: {},
    openid: '',
    session_key: '',
    mask: '',
    keyword: '',
    gps: '重庆',
    more: '../list/list',
    ad: ['../img/ad.jpg', '../img/ad.jpg', '../img/ad.jpg'],
    guide: [{
        url: '../kind/kind',
        src: '../img/g1.jpg',
        name: '休闲娱乐'
      },
      {
        url: '../kind/kind',
        src: '../img/g2.jpg',
        name: '美食外卖'
      },
      {
        url: '../kind/kind',
        src: '../img/g3.jpg',
        name: '培训爱好'
      },
      {
        url: '../kind/kind',
        src: '../img/g4.jpg',
        name: '旅游出行'
      },
      {
        url: '../kind/kind',
        src: '../img/g5.png',
        name: '生活其他'
      }
    ],
    pro: [{
      src: '../img/pro1.jpg',
      icon: '../img/tuan.jpg',
      name: '仅售226元！价值312元的4人自助午餐，提供免费WiFi。',
      now: '226.00',
      price: '200.00',
      url: '../pro/pro'
    }, {
      src: '../img/pro2.jpg',
      icon: '../img/pin.jpg',
      name: '9小时欢唱+酒水套餐',
      now: '226.00',
      price: '20.00',
      url: '../pro/pro'
    }, {
      src: '../img/pro3.jpg',
      icon: '../img/quan.jpg',
      name: '【2店通用】美联英语',
      now: '226.00',
      price: '20.00',
      url: '../pro/pro'
    }, {
      src: '../img/pro4.jpg',
      icon: '../img/quan.jpg',
      name: '重庆动物园',
      now: '226.00',
      price: '20.00',
      url: '../pro/pro'
    }, {
      src: '../img/pro5.jpg',
      icon: '../img/pin.jpg',
      name: '妍姿美睫美甲生活馆',
      now: '226.00',
      price: '20.00',
      url: '../pro/pro'
    }],
    list: [{
      url: '../shop/shop',
      logo: '../img/ll1.png',
      name: '阿利与艾德炭烤麻里牛排海鲜自助烤肉（煌华新纪元购',
      place: '沙坪坝观音桥',
      distance: '256m',
      label: '烧烤烤肉',
      song: '1',
      quan: '38元抵100元代金券',
      pin: '青椒肉丝炒饭10元短标',
      tuan: '4人套餐48.8元, 6人餐228元短标, 4人餐188元（原价264元）短标, 8人餐短标,',
      mian: '冰柠檬水免费赠饮一杯,  回锅肉炒饭一份短标,   '
    }, {
      url: '../shop/shop',
      logo: '../img/ll2.png',
      name: '阿利与艾德炭烤麻里牛排海鲜自助烤肉（煌华新纪元购',
      place: '沙坪坝观音桥',
      distance: '256m',
      label: '烧烤烤肉',
      song: '0',
      quan: '38元抵100元代金券'
    }, {
      url: '../shop/shop',
      logo: '../img/ll1.png',
      name: '阿利与艾德炭烤麻里牛排海鲜自助烤肉（煌华新纪元购',
      place: '沙坪坝观音桥',
      distance: '256m',
      label: '烧烤烤肉',
      song: '1',
      quan: '38元抵100元代金券',
      pin: '青椒肉丝炒饭10元短标',
      mian: '冰柠檬水免费赠饮一杯,  回锅肉炒饭一份短标,   '
    }]
  },
  //事件处理函数
  onShareAppMessage: function() {
    return {
      title: '推荐一个吃喝玩乐平台',
      path: '/page/index/index'
    }
  },
  location: function() {
    wx.navigateTo({
      url: '../gps/gps',
    })
  },
  maskshow: function() {
    this.setData({
      mask: 'active'
    })
  },
  maskhide: function() {
    this.setData({
      mask: ''
    })
  },
  toinput: function(e) {
    this.setData({
      keyword: e.detail.value
    })
  },
  serach: function() {
    wx.showToast({
      title: '搜索' + this.data.keyword,
    })
  },
  onLoad: function() {
    app.userInfoCallback().then(() => {
      var that = this;
      wx.showTabBarRedDot({
        index: 0
      });
      wx.getSystemInfo({
        success: function(res) {
          that.setData({
            scrollHeight: res.windowHeight - 45,
            sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
            sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
          })
        },
      })
      if (params.mod) {
        if (params.mod == 'info') {
          var id = params.id;
          wx.navigateTo({
            url: '../info/info?id=' + id
          })
        }
        if (params.mod == 'detail') {
          var id = params.id;
          wx.navigateTo({
            url: '../detail/detail?id=' + id
          })
        }
      }
      //获取首页数据列表
      getIndexList(that);
    });

  },
  onReady: function() {

  }
})